<?php 
namespace app\modules\cn\models;
use yii\db\ActiveRecord;

class ExerciseTopic extends ActiveRecord {

    public static function tableName(){
        return '{{%exercise_topic}}';
    }

    /**
     * @Title  [获取话题]
     * @Author Don
     * @Date   2021-04-30
     * @param  [type]
     * @param  [type]
     * @return [type]
     */
    public static function getTopic($cate_id, $id=null)
    {
        if (!empty($id)) {
            $res = self::find()->where(['cate_id'=>$cate_id, 'id'=>$id])->asArray()->one();
        } else {
            $res = self::find()->where(['cate_id'=>$cate_id])->asArray()->all();
        }

        return $res;
    }

}
